# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: William J. Bowman <aur@williamjbowman.com>
# Contributer: Leif Warner <abimelech@gmail.com>

_hkgname=transformers-compat
pkgname=haskell-transformers-compat
pkgver=0.7.2
pkgrel=1
pkgdesc="A small compatibility shim exposing the new types from transformers 0.3 to older Haskell platforms."
url="https://hackage.haskell.org/package/${_hkgname}"
license=('BSD')
arch=('loong64' 'x86_64')
depends=('ghc-libs')
makedepends=('ghc')
source=(https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)
sha512sums=('9bcc4b5aebbc6ec0b05ac8499ec79102e766ae8c2c919343f7d20ebb451fedb3a00647dc0baff5e998dd0b67f1ffbe725a14e0abf299a6b2656c219f8330856e')

build() {
    cd $_hkgname-$pkgver
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register   --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
